package com.example.shop_2212.pay

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.example.base.entity.ParamPay
import com.example.base.mvvm.BaseActivity
import com.example.shop_2212.R
import com.example.shop_2212.databinding.ActivityPayBinding

@Route(path = "/app/PayActivity")
class PayActivity : BaseActivity<ActivityPayBinding,PayViewModel>() {
    @Autowired
    @JvmField
    var orderNo = ""
    @Autowired
    @JvmField
    var money = ""
    override fun initView() {
        ARouter.getInstance().inject(this)
        binding.money.text = "总计：$money 元"
        binding.pay.setOnClickListener {
            val paramPay = ParamPay()
            paramPay.orderNo  = orderNo
            paramPay.payType = "yue"
            viewModel.pay(paramPay)
        }
    }

    override fun initData() {
        viewModel.paySuccess.observe(this){
            ToastUtils.showLong(it.message)

        }
    }

    override fun getViewModel(): Class<PayViewModel>  = PayViewModel::class.java

    override fun getLayout(): Int  = R.layout.activity_pay

}